package top.boycharse.blog.dao.bean;


import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import top.boycharse.blog.bean.request.UserInfo;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Table(name = "tb_user")
public class User implements Serializable {

    @Id
    private String userName;

    private String password;

    private String capacity;

    public User() {
    }

    public User(UserInfo userInfo) {
        PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        this.userName = userInfo.getUsername();
        // 对密码进行加密
        this.password = passwordEncoder.encode(userInfo.getPassword());
        this.capacity = userInfo.getCapacity();
    }

    public User(String userName) {
        this.userName = userName;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCapacity() {
        return capacity;
    }

    public void setCapacity(String capacity) {
        this.capacity = capacity;
    }
}
